<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
  <link rel="stylesheet" href="../css/index.css">
  <link rel="stylesheet" href="../css/wechatPay.css">
  <title>账户充值</title>
</head>

<body class="wechatPay page-group">
  <div class="page">
    <!-- //<header class="bar bar-nav" id="golbalHeader"></header> -->

    <!-- 这里是页面内容区 -->
    <div class="content">
      <div class="list-block">
        <ul>
          <li>
            <div class="item-content">
              <!-- <div class="item-media"><i class="icon icon-form-email"></i></div> -->
              <div class="item-inner">
                <div class="item-title label">账户余额</div>
                <div class="item-input">
                  <div id="balance"></div>
                </div>
              </div>
            </div>
          </li>
          <li>
              <div class="item-content">
                <!-- <div class="item-media"><i class="icon icon-form-email"></i></div> -->
                <div class="item-inner">
                  <div class="item-title label">充值金额</div>
                  <div class="item-input money">
                    <input type="text" placeholder="请输入充值金额" onblur="wechatPay.changeInput('pay','money')">
                  </div>
                </div>
              </div>
            </li>
        </ul>
        <a href="#" class="button button-fill" onclick="wechatPay.http('pay')">立即充值</a>
      </div>


    </div>
    <!-- 底部 -->

  </div>
  <!-- 标题栏 -->

</body>
<script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
<script type="text/javascript" src="../js/index.js"></script>
<script type="text/javascript">
  var wechatPay = (function ($) {
    $.init()
    var wechatPay = new ST({
      golbalHeaderText: '账户充值',
      golbalHeaderFunc: function () {
        window.location.href = './userCenter.html'
      },
      pay:{
        money:""
      }
    })

    wechatPay.pushAjax({
      pay:{
        url:'/app/api/private/user/recharge',
        data:wechatPay.pay
      },
      wallet: {
        url: '/app/api/private/money/getMoney',
        data: {}
      }
    })
    wechatPay.pushAjaxSuccess({
      wallet: function (res) {
        if (res.code === '1') {
          $('#balance').text('￥' + res.data.money.balance)
        }
      },
      pay:function (res) {
        if(res.code === '1'){
          $.toast("生成充值订单成功")
          setTimeout(function () {
            window.location.href = './payOnline.html?orderId=' + res.data.order.orderId
          },1e3)
        }else{
          $.toast("生成充值订单失败")
        }
      }
    })

    wechatPay.http('wallet')
    wechatPay.render()
    return wechatPay
  })($)
</script>

</html>